package cn.chenhuanming.shh.administer.entity.jpa;

import com.fasterxml.jackson.annotation.JsonProperty;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * UserSystem entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "user_system", catalog = "house")
public class UserSystem implements java.io.Serializable {

	// Fields

	private String username;
	private UserRole userRole;
	private String password;
	private String roleName;
	private String name;
	private String phone;
	private String description;
	private Set<UserBroker> userBrokers = new HashSet<UserBroker>(0);
	private Set<Article> articles = new HashSet<Article>(0);

	// Constructors

	/** default constructor */
	public UserSystem() {
	}

	/** minimal constructor */
	public UserSystem(String username, UserRole userRole, String password,
			String roleName, String name, String phone) {
		this.username = username;
		this.userRole = userRole;
		this.password = password;
		this.roleName = roleName;
		this.name = name;
		this.phone = phone;
	}

	/** full constructor */
	public UserSystem(String username, UserRole userRole, String password,
			String roleName, String name, String phone, String description,
			Set<UserBroker> userBrokers, Set<Article> articles) {
		this.username = username;
		this.userRole = userRole;
		this.password = password;
		this.roleName = roleName;
		this.name = name;
		this.phone = phone;
		this.description = description;
		this.userBrokers = userBrokers;
		this.articles = articles;
	}

	// Property accessors
	@Id
	@Column(name = "username", unique = true, nullable = false, length = 30)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "role_id", nullable = false)
	public UserRole getUserRole() {
		return this.userRole;
	}

	public void setUserRole(UserRole userRole) {
		this.userRole = userRole;
	}

	@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
	@Column(name = "password", nullable = false, length = 20)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "role_name", nullable = false, length = 20)
	public String getRoleName() {
		return this.roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	@Column(name = "name", nullable = false, length = 20)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "phone", nullable = false, length = 20)
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "description")
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userSystem")
	public Set<UserBroker> getUserBrokers() {
		return this.userBrokers;
	}

	public void setUserBrokers(Set<UserBroker> userBrokers) {
		this.userBrokers = userBrokers;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "userSystem")
	public Set<Article> getArticles() {
		return this.articles;
	}

	public void setArticles(Set<Article> articles) {
		this.articles = articles;
	}

}